/*
 * $Id: BoxPanel.java 59 2009-04-16 08:54:11Z meyer@alphatec.de $
 * 
 *
 * Copyright 2009 DeltaDesk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package deltadesk.gui.deltagui.widget;


/**
 * BoxPanel.
 * 
 * @author Andreas Meyer
 * @version $Revision: 59 $
 */
public class BoxPanel extends Panel {

	
	/**
	 * Construct the box panel.
	 * 
	 */
	public BoxPanel() {
		super();
	}

	/**
	 * Construct the box panel.
	 * 
	 * @param rows
	 * @param cols
	 */
	public BoxPanel(int rows, int cols) {
		super(rows, cols);
		
	}

	/**
	 * @see deltadesk.gui.deltagui.widget.Composite#add(deltadesk.gui.deltagui.widget.Control)
	 */
	public void add(final Control childControl) {
		add(new Box(childControl));
	}

	/**
	 * @see deltadesk.gui.deltagui.widget.Composite#add(deltadesk.gui.deltagui.widget.Control)
	 */
	public void add(final Box childControl) {
		super.add(childControl);
	}

	/**
	 * @see deltadesk.gui.deltagui.widget.Control#setParent(deltadesk.gui.deltagui.widget.Composite)
	 */
	public void setParent(final Composite parent) {
		super.setParent(parent);
		
		if(parent != null) {
			
			final int pg = parent.getInsets().getGap();
			if(pg < 4) {
				getInsets().setGap(2);				
			} else {
				getInsets().setGap(pg/2);	
			}
		}
	}

}
